package com.cookbook.cookbookservice.common.config;

import com.cookbook.cookbookservice.common.base.BaseResponse;
import com.cookbook.cookbookservice.common.exception.BizException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @program: mid-tourism-service
 * @ClassName GlobalBusinessExceptionHandler
 * @description:
 * @author: MiaoChao
 * @create: 2024-02-28 23:24
 * @Version 1.0
 **/
@Slf4j
@RestControllerAdvice
public class GlobalBusinessExceptionHandler {


    @ExceptionHandler(value = BizException.class)
    public BaseResponse bizExceptionHandler(BizException e) {
        log.info("system error:" + e);
        return BaseResponse.fail(e.getCode(), e.getMessage());
    }
}